package com.wxy.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import com.wxy.domain.MyExceptionHandle;

@ControllerAdvice
public class ExceptionHandle {
	@ExceptionHandler(Exception.class)
	public ModelAndView exceptionHandle(Exception ex) {
		ModelAndView modelAndView = new ModelAndView();
		if(ex instanceof Exception)
			modelAndView.addObject("exception",ex.getMessage());
		modelAndView.setViewName("error");
		return modelAndView;
	}
	@ExceptionHandler(MyExceptionHandle.class)
	public ModelAndView exceptionHandle2(MyExceptionHandle ex) {
		ModelAndView modelAndView = new ModelAndView();
		if(ex instanceof Exception)
			modelAndView.addObject("exception",ex.getMessage());
		modelAndView.setViewName("error");
		return modelAndView;
	}
}
